Landcover Notebook¶

This notebook is being used to analyze the landcover in the area surrounding Lake Malawi. The work relies on data from the Sentinel-2 earth observation mission.

Dependencies¶

Here we'll import dependencies that can be used in other cells in this notebook.

In [ ]:
import folium
import json
import matplotlib.pyplot as plt
import numpy as np
import pyproj
import rasterio
from rasterio.enums import Resampling
from rasterio.mask import mask
from shapely.geometry import box, shape
from shapely.ops import transform

Helpers¶

Here we'll define some helper methods that can be used in other cells in this notebook.

In [10]:
classes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
colors = [
  "#419bdf",
  "#397d49",
  "#7a87c6",
  "#e49635",
  "#c4281b",
  "#a59b8f",
  "#a8ebff",
  "#616161",
  "#e3e2c3",
]
labels = [
  "Water",
  "Trees",
  "Flooded",
  "Crops",
  "Built Area",
  "Bare Ground",
  "Snow/Ice",
  "Clouds",
  "Rangeland"
]
years = [2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024]

# File helpers

def input_path(filename):
  return f"../data/input/{filename}"

def output_path(filename):
  return f"../data/output/{filename}"

# Coordinate helpers

def get_crs(path):
  with rasterio.open(path) as file:
    return file.crs

def peek_coordinates(coordinates):
  # Peek at the data
  first_three_coordinates = coordinates[:3]
  last_three_coordinates = coordinates[-3:]
  print(f"{first_three_coordinates}...{last_three_coordinates}")

# Raster helpers
def create_mask(file, type, coords):
  geometry = {
    "type": type,
    "coordinates": coords
  }
  return mask(file, [geometry], crop=True, nodata=file.nodata)
  
def get_stats_from_mask(masked_data, file):
  valid_data = masked_data[masked_data != file.nodata]
  unique_values, counts = np.unique(valid_data, return_counts=True)
  stats = {
    "classes": {},
    "num_classes": len(unique_values),
    "num_pixels": len(valid_data),
  }
  for value, count in zip(unique_values, counts):
    percentage = (count / len(valid_data)) * 100
    stats["classes"][f"Class {int(value)}"] = {
      "pixels": count,
      "percentage": percentage 
    }
  return stats

Lake Malawi Coordinates¶

We need to get the coordinates of the perimiter of the Lake Malawi. For this, we'll use a geojson file obtained from PyGeoAPI.

In [11]:
with open(input_path("lake_malawi.json"), 'r') as f:
    malawi_data = json.load(f)

malawi_coordinates = malawi_data['geometry']['coordinates'][0][0]
peek_coordinates(malawi_coordinates)
[35.2602047055542, -14.277474460510291]...[35.2602047055542, -14.277474460510291]

Map Lake Malawi¶

Lets take a peek at Lake Malawi.

In [12]:
map = folium.Map(location=[-11.6701, 34.6857], zoom_start=7)
folium.GeoJson(malawi_data).add_to(map)
map
Out[12]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Coordinate Reference System¶

In order to buffer the coordinates for Lake Malawi by 25km around the permiter and subsequently mask the geotiff files, we need to find out what coordinate reference system (CRS) we are working with. The CRS is embedded in the geotiff files.

In [13]:
crs = None
for year in years:
  crs_from_file = get_crs(input_path(f"malawi_{year}.tif"))
  if crs and crs != crs_from_file:
    raise "File has unexpected CRS"
  crs = crs_from_file
print(crs)
EPSG:32736

Buffered Lake Malawi Coordinates¶

Using the Lake Malawi coordinates and the known CRS, we will define a 25km buffer, defining new coordinates for the region of interest, which will be the lake and the 25km surrounding it.

In [14]:
malawi_geometry = shape(malawi_data['geometry'])

# Define coordinate transformation
# WGS84 (lat/lon) to a projected CRS so we can work accurately with area
transformer_to_utm = pyproj.Transformer.from_crs("EPSG:4326", crs, always_xy=True)
transformer_to_wgs84 = pyproj.Transformer.from_crs(crs, "EPSG:4326", always_xy=True)

# Transform to UTM (meters)
malawi_utm = transform(transformer_to_utm.transform, malawi_geometry)

# Buffer by 25km (25000 meters)
malawi_buffered = malawi_utm.buffer(25000)
malawi_buffered_coordinates = [list(malawi_buffered.exterior.coords)]

# Get the coordinates of the buffered perimter
malawi_buffered_wgs84 = transform(transformer_to_wgs84.transform, malawi_buffered)
malawi_buffered_wgs84_coordinates = [list(malawi_buffered_wgs84.exterior.coords)]
peek_coordinates(malawi_buffered_wgs84_coordinates)
[[(35.47707019386036, -14.19831045178232), (35.48353826652505, -14.217793727933875), (35.488171765266706, -14.237768211671032), (35.490932165245425, -14.258069838171183), (35.49179629546826, -14.278531816488693), (35.49075654464328, -14.298985995982939), (35.48782094029584, -14.319264245254097), (35.463971413975486, -14.44308510613051), (35.45876973377491, -14.464348288505134), (35.451481982267545, -14.485021816654664), (35.44217586254426, -14.504911914042387), (35.43093805487944, -14.523832086055018), (35.41787342399601, -14.541604873149732), (35.40310405270016, -14.55806352140359), (35.386768110284095, -14.57305355451169), (35.369018565791535, -14.586434232128523), (35.3500217578672, -14.598079880450072), (35.32995583444355, -14.607881082088564), (35.30900907693561, -14.615745713587659), (35.28737812489372, -14.621599820352737), (35.26526611818628, -14.625388320315738), (35.24288077472824, -14.627075529301862), (35.22043242252222, -14.626645502797926), (35.19813200532235, -14.624102190621302), (35.176189081556174, -14.619469402833264), (35.1548098362417, -14.612790587108915), (35.13419512551086, -14.60412841964682), (35.11453857300012, -14.593564213551373), (35.096024736798704, -14.581197150428274), (35.078827364864686, -14.567143342677516), (35.06310775584146, -14.551534735627946), (34.90538347947306, -14.378731176916634), (34.898021604340556, -14.389270579967956), (34.883933154733114, -14.40740268458517), (34.86804335055688, -14.424061405362687), (34.85051310109111, -14.439077558964824), (34.83152008799558, -14.452298594382686), (34.811256964777115, -14.463590153888948), (34.789929398386, -14.472837449718307), (34.76775397300152, -14.479946441869515), (34.744955977724, -14.484844804459346), (34.72176710130998, -14.487482670251419), (34.69842305824061, -14.487833145308242), (34.67516117128016, -14.485892588146077), (34.65221793624258, -14.481680650279786), (34.629826594930044, -14.475240077597276), (34.60821474213054, -14.46663627456686), (34.587601992164394, -14.455956635824025), (34.56819772975758, -14.44330965217374), (34.5501989690071, -14.4288238004478), (34.533788342907684, -14.412646228945727), (34.51913224435383, -14.39494125233344), (34.3594056450187, -14.180456038477432), (34.34777497928374, -14.163210656596632), (34.337807491986354, -14.14500102615036), (34.32958610857489, -14.125979342653716), (34.32317910417602, -14.106304555147533), (34.3186395453922, -14.086141032824782), (34.316004861194344, -14.065657187508757), (34.3152965460028, -14.045024063657962), (34.31902311088686, -13.747788769412766), (34.13780347169841, -13.517056452360542), (34.12510519979362, -13.49913765915147), (34.114232500643084, -13.4801041817296), (34.105286306772065, -13.46013344554673), (34.098349524532466, -13.439411573213372), (34.09348627654869, -13.418131643416071), (34.09074132189991, -13.396491886519334), (34.09013965875911, -13.374693833894641), (34.09859650490662, -12.985555710842416), (33.81881322478447, -12.291735467978812), (33.81177851879637, -12.271475577782951), (33.80672519734203, -12.250651926875786), (33.80369815094548, -12.229451413121623), (33.802724058739045, -12.208064273716827), (33.80381116623153, -12.186682375942446), (33.80694922900565, -12.16549749489286), (33.81210962221166, -12.144699593647493), (33.819245614251805, -12.12447512127258), (33.82829280161368, -12.105005343826205), (34.090527112586294, -11.60376106314986), (34.03441669001991, -10.510275908787255), (33.70605460586311, -9.90928658736391), (33.69648816532653, -9.889495160736555), (33.68890307589478, -9.868877014122889), (33.68337049736507, -9.847626575279122), (33.67994219993334, -9.825944198848143), (33.6786500903565, -9.804034274150649), (33.679505926485035, -9.78210329635905), (33.682501222261855, -9.76035791930653), (33.68760734347931, -9.739003008298166), (33.77678454047671, -9.432756716951495), (33.78413092874566, -9.411522725829501), (33.79356096826266, -9.39111675230756), (33.804981366812996, -9.371739878603599), (33.8182792722237, -9.353583010858616), (33.833323393872696, -9.336825003081884), (33.84996530309474, -9.32163090065757), (33.8680408994921, -9.308150320466), (33.887372028635205, -9.296515983320045), (33.907768235256974, -9.286842412917917), (33.929028634813825, -9.279224813880974), (33.95094388521654, -9.27373813969657), (33.973298239633536, -9.270436359535124), (33.9958716605439, -9.269351930976939), (34.01844197467468, -9.270495483685252), (34.04078704809925, -9.273855717017094), (34.062686960605284, -9.279399512492724), (34.083926158461026, -9.287072259966884), (34.10429556491837, -9.296798394282142), (34.123594628186645, -9.30848213715483), (34.14163328718938, -9.322008437066895), (34.158233836171064, -9.337244098031434), (34.68682462907354, -9.871693078503695), (34.70193302171426, -9.888530589016513), (34.71527679482443, -9.906775614784785), (34.72672320118735, -9.926246974316832), (34.73615826951539, -9.946751289617549), (34.74348794317016, -9.968084899809604), (34.74863902425353, -9.990035877318713), (34.75155991339243, -10.012386126940648), (34.830095664844436, -10.989942621399157), (35.11151579785281, -11.317093817062567), (35.12478248217734, -11.33405650794552), (35.13636288749836, -11.352182398464574), (35.14615274217831, -11.371308701129344), (35.15406379565459, -11.39126362372068), (35.16002461883554, -11.411867906149832), (35.163981255988865, -11.432936424924845), (35.16589772196135, -11.45427985108674), (35.16575633986412, -11.4757063469789), (35.163557915706996, -11.497023286832878), (35.15932174786272, -11.518038985899372), (34.927564431730474, -12.435298009560695), (35.07515351616887, -13.515539069363857), (35.10700689877398, -13.522599627525736), (35.1290484143779, -13.528620333738987), (35.150373648163445, -13.536744382406662), (35.1707736337812, -13.546892097196178), (35.19004841565827, -13.558963974687906), (35.20800899576726, -13.572841655077823), (35.224479176305806, -13.588389076307857), (35.239297280741525, -13.605453800579271), (35.2523177367293, -13.623868500574247), (35.263412505603945, -13.643452591195095), (35.27247234448313, -13.664013991240132), (35.47707019386036, -14.19831045178232)]]...[[(35.47707019386036, -14.19831045178232), (35.48353826652505, -14.217793727933875), (35.488171765266706, -14.237768211671032), (35.490932165245425, -14.258069838171183), (35.49179629546826, -14.278531816488693), (35.49075654464328, -14.298985995982939), (35.48782094029584, -14.319264245254097), (35.463971413975486, -14.44308510613051), (35.45876973377491, -14.464348288505134), (35.451481982267545, -14.485021816654664), (35.44217586254426, -14.504911914042387), (35.43093805487944, -14.523832086055018), (35.41787342399601, -14.541604873149732), (35.40310405270016, -14.55806352140359), (35.386768110284095, -14.57305355451169), (35.369018565791535, -14.586434232128523), (35.3500217578672, -14.598079880450072), (35.32995583444355, -14.607881082088564), (35.30900907693561, -14.615745713587659), (35.28737812489372, -14.621599820352737), (35.26526611818628, -14.625388320315738), (35.24288077472824, -14.627075529301862), (35.22043242252222, -14.626645502797926), (35.19813200532235, -14.624102190621302), (35.176189081556174, -14.619469402833264), (35.1548098362417, -14.612790587108915), (35.13419512551086, -14.60412841964682), (35.11453857300012, -14.593564213551373), (35.096024736798704, -14.581197150428274), (35.078827364864686, -14.567143342677516), (35.06310775584146, -14.551534735627946), (34.90538347947306, -14.378731176916634), (34.898021604340556, -14.389270579967956), (34.883933154733114, -14.40740268458517), (34.86804335055688, -14.424061405362687), (34.85051310109111, -14.439077558964824), (34.83152008799558, -14.452298594382686), (34.811256964777115, -14.463590153888948), (34.789929398386, -14.472837449718307), (34.76775397300152, -14.479946441869515), (34.744955977724, -14.484844804459346), (34.72176710130998, -14.487482670251419), (34.69842305824061, -14.487833145308242), (34.67516117128016, -14.485892588146077), (34.65221793624258, -14.481680650279786), (34.629826594930044, -14.475240077597276), (34.60821474213054, -14.46663627456686), (34.587601992164394, -14.455956635824025), (34.56819772975758, -14.44330965217374), (34.5501989690071, -14.4288238004478), (34.533788342907684, -14.412646228945727), (34.51913224435383, -14.39494125233344), (34.3594056450187, -14.180456038477432), (34.34777497928374, -14.163210656596632), (34.337807491986354, -14.14500102615036), (34.32958610857489, -14.125979342653716), (34.32317910417602, -14.106304555147533), (34.3186395453922, -14.086141032824782), (34.316004861194344, -14.065657187508757), (34.3152965460028, -14.045024063657962), (34.31902311088686, -13.747788769412766), (34.13780347169841, -13.517056452360542), (34.12510519979362, -13.49913765915147), (34.114232500643084, -13.4801041817296), (34.105286306772065, -13.46013344554673), (34.098349524532466, -13.439411573213372), (34.09348627654869, -13.418131643416071), (34.09074132189991, -13.396491886519334), (34.09013965875911, -13.374693833894641), (34.09859650490662, -12.985555710842416), (33.81881322478447, -12.291735467978812), (33.81177851879637, -12.271475577782951), (33.80672519734203, -12.250651926875786), (33.80369815094548, -12.229451413121623), (33.802724058739045, -12.208064273716827), (33.80381116623153, -12.186682375942446), (33.80694922900565, -12.16549749489286), (33.81210962221166, -12.144699593647493), (33.819245614251805, -12.12447512127258), (33.82829280161368, -12.105005343826205), (34.090527112586294, -11.60376106314986), (34.03441669001991, -10.510275908787255), (33.70605460586311, -9.90928658736391), (33.69648816532653, -9.889495160736555), (33.68890307589478, -9.868877014122889), (33.68337049736507, -9.847626575279122), (33.67994219993334, -9.825944198848143), (33.6786500903565, -9.804034274150649), (33.679505926485035, -9.78210329635905), (33.682501222261855, -9.76035791930653), (33.68760734347931, -9.739003008298166), (33.77678454047671, -9.432756716951495), (33.78413092874566, -9.411522725829501), (33.79356096826266, -9.39111675230756), (33.804981366812996, -9.371739878603599), (33.8182792722237, -9.353583010858616), (33.833323393872696, -9.336825003081884), (33.84996530309474, -9.32163090065757), (33.8680408994921, -9.308150320466), (33.887372028635205, -9.296515983320045), (33.907768235256974, -9.286842412917917), (33.929028634813825, -9.279224813880974), (33.95094388521654, -9.27373813969657), (33.973298239633536, -9.270436359535124), (33.9958716605439, -9.269351930976939), (34.01844197467468, -9.270495483685252), (34.04078704809925, -9.273855717017094), (34.062686960605284, -9.279399512492724), (34.083926158461026, -9.287072259966884), (34.10429556491837, -9.296798394282142), (34.123594628186645, -9.30848213715483), (34.14163328718938, -9.322008437066895), (34.158233836171064, -9.337244098031434), (34.68682462907354, -9.871693078503695), (34.70193302171426, -9.888530589016513), (34.71527679482443, -9.906775614784785), (34.72672320118735, -9.926246974316832), (34.73615826951539, -9.946751289617549), (34.74348794317016, -9.968084899809604), (34.74863902425353, -9.990035877318713), (34.75155991339243, -10.012386126940648), (34.830095664844436, -10.989942621399157), (35.11151579785281, -11.317093817062567), (35.12478248217734, -11.33405650794552), (35.13636288749836, -11.352182398464574), (35.14615274217831, -11.371308701129344), (35.15406379565459, -11.39126362372068), (35.16002461883554, -11.411867906149832), (35.163981255988865, -11.432936424924845), (35.16589772196135, -11.45427985108674), (35.16575633986412, -11.4757063469789), (35.163557915706996, -11.497023286832878), (35.15932174786272, -11.518038985899372), (34.927564431730474, -12.435298009560695), (35.07515351616887, -13.515539069363857), (35.10700689877398, -13.522599627525736), (35.1290484143779, -13.528620333738987), (35.150373648163445, -13.536744382406662), (35.1707736337812, -13.546892097196178), (35.19004841565827, -13.558963974687906), (35.20800899576726, -13.572841655077823), (35.224479176305806, -13.588389076307857), (35.239297280741525, -13.605453800579271), (35.2523177367293, -13.623868500574247), (35.263412505603945, -13.643452591195095), (35.27247234448313, -13.664013991240132), (35.47707019386036, -14.19831045178232)]]

Save Buffered Lake Malawi Coordinates¶

We will save a new geojson file with the buffered coordinates.

In [15]:
expanded_geojson = {
  "type": "Feature",
  "properties": {
    "id": 10,
    "scalerank": 0,
    "name": "Lake Malawi",
    "name_alt": "Lake Nyasa",
    "admin": "admin-0",
    "featureclass": "Lake"
  },
  "geometry": {
    "type": malawi_buffered_wgs84.geom_type,
    "coordinates": malawi_buffered_wgs84_coordinates
  },
  "id": 10
}

with open(output_path("lake_malawi_expanded_25km.json"), "w") as dst:
  json.dump(expanded_geojson, dst, indent=2)

Map Lake Malawi and Surrounding 25KM¶

Map the expanded boundary of Lake Malawi.

In [16]:
folium.GeoJson(expanded_geojson).add_to(map)
map
Out[16]:
Make this Notebook Trusted to load map: File -> Trust Notebook

Visualize Landcover for Greater Region¶

Let's visualize the landcover for the greater region using the original geotiff files.

In [25]:
for year in years:
  print(year)
  with rasterio.open(input_path(f"malawi_{year}.tif")) as file:
    downsampled_data = file.read(
        out_shape=(
            file.count,
            int(file.height * 0.1),
            int(file.width * 0.1)
        ),
        resampling=Resampling.bilinear
    )

    fig, ax = plt.subplots(1, 1, figsize=(10, 10))
    rasterio.plot.show(downsampled_data, ax=ax, transform=file.transform, title = f"Landcover in {year}")
    plt.show()
    
2017
No description has been provided for this image
2018
No description has been provided for this image
2019
No description has been provided for this image
2020
No description has been provided for this image
2021
No description has been provided for this image
2022
No description has been provided for this image
2023
No description has been provided for this image
2024
No description has been provided for this image

Analyze Land Cover within Buffered Lake Malawi Coordinates¶

The geotiff files contain the land cover data for a large region surrounding Lake Malawi. We'll mask the files to get the cover for the immediate area surrounding the lake.

In [19]:
for year in years:
  with rasterio.open(input_path(f"malawi_{year}.tif")) as file:
    masked_data, masked_transform = create_mask(
      file,
      malawi_buffered.geom_type,
      malawi_buffered_coordinates
    )
    bounding_box = box(*file.bounds)
    if bounding_box.intersects(malawi_buffered):
      print(f"\n{year}")
      
      stats = get_stats_from_mask(masked_data, file)
      print(f"Number of pixels: {stats["num_pixels"]}")
      print(f"Number of land cover classes: {stats["num_classes"]}")

      for cls in stats["classes"]:
        print(f"{cls}: {stats["classes"][cls]["pixels"]:,} pixels ({stats["classes"][cls]["percentage"]:.2f}%)")
    else:
      print("No overlap detected. Mask is not correct")

    output_profile = file.profile.copy()
    output_profile.update({
      'height': masked_data.shape[1],
      'width': masked_data.shape[2],
      'transform': masked_transform
    })
    with rasterio.open(output_path(f"malawi_{year}_masked.tif"), 'w', **output_profile) as dst:
      dst.write(masked_data)
2017
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,062,405 pixels (49.81%)
Class 2: 94,756,092 pixels (15.94%)
Class 4: 279,097 pixels (0.05%)
Class 5: 23,663,623 pixels (3.98%)
Class 7: 8,954,681 pixels (1.51%)
Class 8: 163,789 pixels (0.03%)
Class 10: 5,742 pixels (0.00%)
Class 11: 170,464,298 pixels (28.68%)

2018
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,140,745 pixels (49.83%)
Class 2: 110,617,108 pixels (18.61%)
Class 4: 544,220 pixels (0.09%)
Class 5: 22,283,444 pixels (3.75%)
Class 7: 10,205,910 pixels (1.72%)
Class 8: 96,417 pixels (0.02%)
Class 10: 84,383 pixels (0.01%)
Class 11: 154,377,500 pixels (25.97%)

2019
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,188,895 pixels (49.83%)
Class 2: 110,611,997 pixels (18.61%)
Class 4: 458,157 pixels (0.08%)
Class 5: 23,421,564 pixels (3.94%)
Class 7: 10,550,809 pixels (1.78%)
Class 8: 83,680 pixels (0.01%)
Class 10: 25,875 pixels (0.00%)
Class 11: 153,008,750 pixels (25.74%)

2020
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,398,142 pixels (49.87%)
Class 2: 100,409,978 pixels (16.89%)
Class 4: 816,341 pixels (0.14%)
Class 5: 25,856,763 pixels (4.35%)
Class 7: 10,615,203 pixels (1.79%)
Class 8: 57,904 pixels (0.01%)
Class 10: 6,062 pixels (0.00%)
Class 11: 160,189,334 pixels (26.95%)

2021
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,437,041 pixels (49.88%)
Class 2: 86,120,127 pixels (14.49%)
Class 4: 916,144 pixels (0.15%)
Class 5: 26,686,570 pixels (4.49%)
Class 7: 11,680,205 pixels (1.97%)
Class 8: 46,410 pixels (0.01%)
Class 10: 16,203 pixels (0.00%)
Class 11: 172,447,027 pixels (29.01%)

2022
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,576,042 pixels (49.90%)
Class 2: 95,916,954 pixels (16.14%)
Class 4: 1,297,987 pixels (0.22%)
Class 5: 30,356,672 pixels (5.11%)
Class 7: 12,271,820 pixels (2.06%)
Class 8: 38,917 pixels (0.01%)
Class 10: 22,781 pixels (0.00%)
Class 11: 157,868,554 pixels (26.56%)

2023
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 296,870,362 pixels (49.95%)
Class 2: 94,974,139 pixels (15.98%)
Class 4: 2,233,678 pixels (0.38%)
Class 5: 27,576,826 pixels (4.64%)
Class 7: 12,267,058 pixels (2.06%)
Class 8: 28,997 pixels (0.00%)
Class 10: 24,131 pixels (0.00%)
Class 11: 160,374,536 pixels (26.98%)

2024
Number of pixels: 594349727
Number of land cover classes: 8
Class 1: 297,201,661 pixels (50.00%)
Class 2: 103,221,610 pixels (17.37%)
Class 4: 2,786,235 pixels (0.47%)
Class 5: 31,337,596 pixels (5.27%)
Class 7: 12,553,491 pixels (2.11%)
Class 8: 35,388 pixels (0.01%)
Class 10: 4,004 pixels (0.00%)
Class 11: 147,209,742 pixels (24.77%)

Visualize Landcover for Greater Region¶

Let's visualize the landcover for the greater region using the original geotiff files.

In [26]:
for year in years:
  print(year)
  with rasterio.open(output_path(f"malawi_{year}_masked.tif")) as file:
    downsampled_data = file.read(
        out_shape=(
            file.count,
            int(file.height * 0.1),
            int(file.width * 0.1)
        ),
        resampling=Resampling.bilinear
    )

    fig, ax = plt.subplots(1, 1, figsize=(10, 10))
    rasterio.plot.show(downsampled_data, ax=ax, transform=file.transform, title = f"Landcover in {year}")
    plt.show()
2017
No description has been provided for this image
2018
No description has been provided for this image
2019
No description has been provided for this image
2020
No description has been provided for this image
2021
No description has been provided for this image
2022
No description has been provided for this image
2023
No description has been provided for this image
2024
No description has been provided for this image